package com.bolingcavalry.crm.serviceorder.mapper;/*
 * @Auther:Sadie
 * @Date:2025/4/24
 * @Description:
 * @VERSON:1.8
 */

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.entity.serviceorder.ServiceOrder;
import com.vo.ServiceOrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ServiceOrderMapper extends BaseMapper<ServiceOrder> {
    //查询任务单号是否已经存在
    @Select("select count(*) from service_orders where service_order_number = #{serviceOrderNumber} and is_deleted = 1 ")
    boolean selectByServiceOrderNumber(String serviceOrderNumber);


    //IPage<ServiceOrder> pageByConditions(Page<ServiceOrder> page, LambdaQueryWrapper<ServiceOrder> queryWrapper);

    boolean setisdeleted(Long id);

    boolean updateStatus(Long id, String status);

    @Update("UPDATE service_orders SET status = #{status}, receiver_id = #{receiverId} WHERE id = #{id}")
    boolean updateStatus(@Param("id") Long id,
                         @Param("status") String status,
                         @Param("receiverId") Long receiverId);

    int batchSetIsDeleted(@Param("ids") List<Long> ids);

    IPage<ServiceOrderVO> getByConditions(Page<ServiceOrder> page, String companyName, String salesManagerName, String serviceOrderNumber, String startDate, String endDate, String status);

    //根据售后单号查询对应的数据
    @Select("select * from service_orders where service_order_number = #{orderNumber} and is_deleted=1")
    ServiceOrder selectByOrderNumber(String orderNumber);

    void updateStatusByOrderNumber(String orderNumber, String status);

    boolean getByOrderNumberToDown(String serviceOrderNumber);
}
